/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MaintenancePanel.java
 *
 * Created on Oct 23, 2010, 6:14:38 PM
 */

package lmclogistics;

import components.Lightbox;
import components.Button;
import components.NButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;

/**
 *
 * @author katrina
 */
public class MaintenancePanel extends javax.swing.JPanel {

    private int j = 0;
    private Button maintenanceSubmenu[] = new Button[15];
    private JPanel pl;
    /** Creates new form MaintenancePanel */
    public MaintenancePanel() {
        initComponents();
        initMaintMenus();
        setOpaque(false);
        setLocation(613, 165);
        setSize(287, 340);
        initButtons();



    }

    public void setMaintButton(String button,String rollover,int x, int y){
        maintenanceSubmenu[j] = new Button(button,291,37);
        maintenanceSubmenu[j].setLocation(x,y);
        maintenanceSubmenu[j].setRollover(rollover);
        add(maintenanceSubmenu[j]);
        j++;


    }

    public void initMaintMenus(){
        setMaintButton("chassis.png","chassis selected.png",0,0);
        setMaintButton("trucking.png","trucking selected.png",0,40);
        setMaintButton("consignee.png","consignee selected.png",0,80);
        setMaintButton("suppliers.png","suppliers selected.png",0,120);
        setMaintButton("customer.png","customer selected.png",0,160);
    }

     public void initButtons(){

        maintenanceSubmenu[0].addActionListener(new ActionListener(){


            public void actionPerformed(ActionEvent e) {

                setSize(919,577);
                setLocation(0,0);

                Chassis chassis = new Chassis();

                for(int i=0;i<j;i++)
                     maintenanceSubmenu[i].setVisible(false);

                Main.login.disableButtons();

                pl = new Lightbox(chassis);
                add(pl, 1);

                NButton close = new NButton("Close",740,480);
                pl.add(close,0);
                close.addActionListener(new ActionListener(){
                    public void actionPerformed(ActionEvent e) {
                    remove(pl);
                    setDefault();
                    repaint();
                    Main.login.enableButtons();
                    }
                });

            }
        });

        maintenanceSubmenu[1].addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e) {

                setSize(919,577);
                setLocation(0,0);

                Trucking trucking;
                trucking = new Trucking();
                

                for(int i=0;i<j;i++)
                     maintenanceSubmenu[i].setVisible(false);

                Main.login.disableButtons();

                pl = new Lightbox(trucking);
                add(pl, 1);

                NButton close = new NButton("Close",620,480);
                pl.add(close,0);
                close.addActionListener(new ActionListener(){
                    public void actionPerformed(ActionEvent e) {
                    remove(pl);
                    setDefault();
                    repaint();
                    Main.login.enableButtons();
                    }
                });


            }
        });

        maintenanceSubmenu[2].addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e) {
                setSize(919,577);
                setLocation(0,0);

                Consignee consignee;
                consignee = new Consignee();


                for(int i=0;i<j;i++)
                     maintenanceSubmenu[i].setVisible(false);

                Main.login.disableButtons();

                pl = new Lightbox(consignee);
                add(pl, 1);

                NButton close = new NButton("Close",620,480);
                pl.add(close,0);
                close.addActionListener(new ActionListener(){
                    public void actionPerformed(ActionEvent e) {
                    remove(pl);
                    setDefault();
                    repaint();
                    Main.login.enableButtons();
                    }
                });

            }
        });

        maintenanceSubmenu[3].addActionListener(new ActionListener(){


            public void actionPerformed(ActionEvent e) {

                setSize(919,577);
                setLocation(0,0);

                Supplier supplier = new Supplier();


             for(int i=0;i<j;i++)
                     maintenanceSubmenu[i].setVisible(false);

                Main.login.disableButtons();



                pl = new Lightbox(supplier);
                add(pl, 1);

                NButton close = new NButton("Close",740,480);
                  pl.add(close,0);
                close.addActionListener(new ActionListener(){

                public void actionPerformed(ActionEvent e) {
                    remove(pl);
                    setDefault();
                    repaint();
                    Main.login.enableButtons();

                }
                });
            }
        });

        maintenanceSubmenu[4].addActionListener(new ActionListener(){


            public void actionPerformed(ActionEvent e) {

                setSize(919,577);
                setLocation(0,0);

                Customer customer = new Customer();

                setSize(919,577);

                for(int i=0;i<j;i++)
                     maintenanceSubmenu[i].setVisible(false);

                Main.login.disableButtons();

                pl = new Lightbox(customer);
                add(pl, 1);

                NButton close = new NButton("Close",740,480);
                  pl.add(close,0);
                close.addActionListener(new ActionListener(){

                public void actionPerformed(ActionEvent e) {
                    remove(pl);
                    setDefault();
                    repaint();
                    Main.login.enableButtons();

                }
                });
            }
        });

    }

     public void setDefault(){
            setLocation(613, 165);
            setSize(287, 340);

            for(int i=0;i<j;i++)
                     maintenanceSubmenu[i].setVisible(true);
        }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setOpaque(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents




    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
